
import 'package:snooperlang/src/AstVisitor.dart';
import 'package:snooperlang/src/Scope.dart';
import 'package:snooperlang/src/snooperParser.dart';

import 'Symbol.dart';

/**
 * 把符号加入符号表。
 */
class EnterVisitor extends AstVisitor{
  Scope? scope;  //当前所属的scope
  
  FunctionSymbol? functionSym;

  /// 得到最顶级的Scope对象
  @override
  Object? visitSnooperProg(SnooperProg prog, [Object? o]) {
    var sym = FunctionSymbol('main', []);
    prog.sym = sym;
    prog.scope = Scope(null);
    scope = prog.scope;
    super.visitSnooperProg(prog,o);
  }

  @override
  Object? visitFunctionDecl(FunctionDecl variableDecl, [Object? o]){
    var currentScope = scope as Scope;
    if( currentScope.hasSymbol(variableDecl.name()) ){

    }
  }
}